package ideamaps;

import java.util.ResourceBundle;


import com.taillive.commons.ConvertUtils;

public class Config {
	
	private static Config instance;
	
	public static Config getInstance(){
		if(instance == null){
			instance = new Config();
			instance.init();
		}
		
		return instance;
	}
	
	private void init(){
		ResourceBundle resources = ResourceBundle.getBundle("config.config");
		
		domain = ConvertUtils.trim(resources.getString("domain"));
		defaultCity = ConvertUtils.trim(resources.getString("defaultCity"));
		siteName = ConvertUtils.trim(resources.getString("siteName"));
		basePath = ConvertUtils.trim(resources.getString("basePath"));
		baseUrl = ConvertUtils.trim(resources.getString("baseUrl"));
		uploadPath = ConvertUtils.trim(resources.getString("uploadPath"));
		uploadUrl =ConvertUtils.trim( resources.getString("uploadUrl"));
		emailTemplatePath = ConvertUtils.trim(resources.getString("emailTemplatePath"));
		fmTemplatePath = ConvertUtils.trim(resources.getString("fmTemplatePath"));
		gmapUrl =ConvertUtils.trim( resources.getString("gmapUrl"));
		gmapApiKey= ConvertUtils.trim( resources.getString("gmapApiKey"));
		qqwryFile =ConvertUtils.trim( resources.getString("qqwryFile"));
		cmdConvertImage =ConvertUtils.trim( resources.getString("cmdConvertImage"));
		cleanUrl = "true".equals(ConvertUtils.trim(resources.getString("cleanUrl")).toLowerCase());
	}
	
	private String domain;
	private String defaultCity;
	private String siteName;
	private String basePath;
	private String baseUrl;
	private String uploadPath;
	private String uploadUrl;
	private String qqwryFile;
	private String gmapUrl;
	private String gmapApiKey;
	private String emailTemplatePath;
	private String fmTemplatePath;
	private String cmdConvertImage;
	private boolean cleanUrl;
	private boolean initContextVariables;
	
	public boolean isCleanUrl() {
		return cleanUrl;
	}
	public void setCleanUrl(boolean cleanUrl) {
		this.cleanUrl = cleanUrl;
	}
	public String getBasePath() {
		return basePath;
	}
	public void setBasePath(String basePath) {
		this.basePath = basePath;
	}
	public String getBaseUrl() {
		return baseUrl;
	}
	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	public String getUploadUrl() {
		return uploadUrl;
	}
	public void setUploadUrl(String uploadUrl) {
		this.uploadUrl = uploadUrl;
	}
	public String getEmailTemplatePath() {
		return emailTemplatePath;
	}
	public void setEmailTemplatePath(String emailTemplatePath) {
		this.emailTemplatePath = emailTemplatePath;
	}
	public String getUploadPath() {
		return uploadPath;
	}
	public void setUploadPath(String uploadPath) {
		this.uploadPath = uploadPath;
	}
	public String getSiteName() {
		return siteName;
	}
	public void setSiteName(String siteName) {
		this.siteName = siteName;
	}
	public String getGmapUrl() {
		return gmapUrl;
	}
	public void setGmapUrl(String gmapUrl) {
		this.gmapUrl = gmapUrl;
	}
	public String getDefaultCity() {
		return defaultCity;
	}
	public void setDefaultCity(String defaultCity) {
		this.defaultCity = defaultCity;
	}
	public String getDomain() {
		return domain;
	}
	public void setDomain(String domain) {
		this.domain = domain;
	}
	public String getCmdConvertImage() {
		return cmdConvertImage;
	}
	public void setCmdConvertImage(String cmdConvertImage) {
		this.cmdConvertImage = cmdConvertImage;
	}
	public String getQqwryFile() {
		return qqwryFile;
	}
	public void setQqwryFile(String qqwryFile) {
		this.qqwryFile = qqwryFile;
	}
	public String getFmTemplatePath() {
		return fmTemplatePath;
	}
	public void setFmTemplatePath(String fmTemplatePath) {
		this.fmTemplatePath = fmTemplatePath;
	}
	
	public boolean isInitContextVariables() {
		return initContextVariables;
	}
	public void setInitContextVariables(boolean initContextVariables) {
		this.initContextVariables = initContextVariables;
	}

	public String getGmapApiKey() {
		return gmapApiKey;
	}
	public void setGmapApiKey(String gmapApiKey) {
		this.gmapApiKey = gmapApiKey;
	}


	public static String getCitySite(String city){
		StringBuffer sb = new StringBuffer("http://");
		sb.append(city);
		sb.append(".");
		sb.append(instance.getDomain());
		return sb.toString();
	}
	
	
	
	
}
